package com.demo.web;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.demo.entity.PayCompany;
import com.demo.entity.PayCompanyDetail;
import com.demo.entity.PayCompanyDynamic;
import com.demo.server.NavigationServer;
import com.jweb.annotaion.JAutowired;
import com.jweb.annotaion.JController;
import com.jweb.core.handle.Controller;
import com.jweb.util.FormatUtil;

/**
 * 3导航
 * 
 * @author Yuan
 */
@JController("/navigation")
public class NavigationController extends Controller {
	@JAutowired
	public NavigationServer server;

	public void init() {
		setAttr("menutag", 3);
	}

	public void NavigationManager() {
		List<Map<String, String>> list = server.listAllGroupLocation();
		List<Object> cList = new ArrayList<Object>();
		for (Map<String, String> map : list) {
			List<PayCompany> listC = server.listCompanyByLocation(map.get("location"));
			cList.add(listC);
		}
		setAttr("ListLocation", list);
		setAttr("ListCompany", cList);
	}

	public void NavigationInfo() {
		String company_id = this.getParameterURL().get(0);
		PayCompany mapinfo = server.getCompanyByID(FormatUtil.toInt(company_id));
		setAttr("Info", mapinfo);
		//
		PayCompanyDetail mapdetail = server.getCompanyDetailByID(FormatUtil.toInt(company_id));
		setAttr("Detail", mapdetail);
		//
		List<PayCompanyDynamic> dynamic = server.getCompanyDynamicByID(FormatUtil.toInt(company_id));
		setAttr("Dynamic", dynamic);
	}
}
